<template>
  <div class="rights">
    <!-- 面包屑 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item :to="{ path: '/rights' }">权限管理</el-breadcrumb-item>
      <el-breadcrumb-item>权限列表</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 表格 -->
      <el-table
        :data="rightsList"
        border
        style="width: 100%">
        <el-table-column
          type="index"
          width="50">
        </el-table-column>
        <el-table-column
          prop="authName"
          label="权限名称">
        </el-table-column>
        <el-table-column
          prop="path"
          label="路径">
        </el-table-column>
        <el-table-column
          label="层级">
           <template slot-scope="scope">
              <el-tag v-if="scope.row.level==='0'">一级</el-tag>
              <el-tag type="success" v-else-if="scope.row.level==='1'">二级</el-tag>
              <el-tag type="danger" v-else-if="scope.row.level==='2'">三级</el-tag>
          </template>
        </el-table-column>
      </el-table>
  </div>
</template>

<script>
import { getAllRightsList } from '@/api'
export default {
  data () {
    return {
      rightsList: []
    }
  },
  created () {
    this.initTable()
  },
  methods: {
    // 初始化表格
    initTable () {
      getAllRightsList('list').then(res => {
        this.rightsList = res.data
        console.log(res)
        // this.aabb()
      })
    }
    // aabb () {
    //   this.rightsList.map((item, index) => {
    //     // console.log(item)
    //     if (item.level === '0') {
    //       console.log(index)
    //     }
    //   })
    // }
  }
}
</script>

<style lang="scss" scoped>

</style>
